<template>
    <view class="content">
        <view class="top" @click="show = true">
			{{ date }}
			<u-icon name="arrow-down-fill" color="#a5a5a5" size="24" class="u-m-l-15"></u-icon>
		</view>
		
		<view class="box">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view>{{item.type}}</view>
				<view class="name">{{item.user_name}}</view>
				<view class="text-bold">人数{{item.num}}</view>
			</view>
		</view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
		
		<u-picker v-model="show" mode="time" @confirm="confirmDate"></u-picker>
    </view>
</template>

<script>
    export default {
        data() {
            return {
				show: false,
                date: '请选择',
				status: 'loadmore', //是否显示没有更多了
				page: 1,
				list: [], 
            };
        },
        onLoad() {
            const now = new Date();
            const year = now.getFullYear();
            const month = now.getMonth() + 1; // 月份从0开始，需要加1
            const day = now.getDate();
            this.date = year + '-' + (month > 10 ? month : '0' + month) + '-' + day
			
			this.getList()
        },
		onReachBottom() {
			if(this.page == 1){return}
			this.getList()
		},
        methods: {
            // 选择日期
            confirmDate(e) {
            	console.log(e)
            	this.date = e.year + '-' + e.month + '-' + e.day
				this.page = 1
				this.list = []
				this.status = 'loadmore'
				this.getList()
            },
			
			getList() {
				if (this.status == 'nomore') return;
				this.status = 'loading';
				this.$ajax('operation_sign_count', {
					user_token: this.$getSync('userToken'),
					page: this.page,
					limit: 10,
			        date: this.date,//时间搜索
				}).then(ret => {
					if (ret.success == 1000) {
						if (ret.detail.data.length > 0) {
							this.list = this.list.concat(ret.detail.data);
							this.page++;
							this.status = 'loadmore'
						} else {
							this.status = 'nomore'
						}
					} else {
						this.$toast(ret.msg);
					}
				});
			},
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
	.content{
		padding: 30rpx 20rpx;
	}
	.top{
		padding-bottom: 25rpx;
	}
	
	.box{
		padding: 0 25rpx;
		background-color: #fff;
		border-radius: 15rpx;
	}
	.item{
		padding: 35rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 2rpx solid #e6e6e6;
	}
	.item:last-child{
		border-bottom: none;
	}
	.name{
		flex: 1;
		font-weight: bold;
		padding-left: 20rpx;
		padding-right: 50rpx;
	}
	
	
	

</style>
